package com.lmabbe.core.common.entitys;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.IsNativeDefValue;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.lmabbe.common.global.constant.GlobalConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author lmabbe
 * @TableName sys_user
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "部门表")
@TableName(autoResultMap = true)
@Table(isSimple = true, comment = "部门表")
public class SysOrg implements Serializable {

    /**
     * ID
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "ID")
    @Column(isKey = true, isNull = false, length = 32, comment = "部门ID")
    private Long orgId;

    /**
     * 名称
     */
    @TableField()
    @ApiModelProperty(value = "名称")
    @Column(comment = "名称", isNull = false)
    private String label;

    /**
     * 父ID
     */
    @TableField()
    @ApiModelProperty(value = "父ID")
    @Column(comment = "父ID")
    private Long parentId;

    /**
     * 树结构
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    @ApiModelProperty(value = "树结构")
    @Column(comment = "树结构", type = MySqlTypeConstant.JSON)
    private List<Long> treePath;

    /**
     * 排序
     */
    @TableField()
    @ApiModelProperty(value = "排序")
    @Column(comment = "排序，越小越靠前", defaultValue = "0")
    private Integer sortValue;

    /**
     * 是否有效(1.有效 0.无效 -1.软删除)
     */
    @TableField()
    @ApiModelProperty(value = "是否有效(1.有效 0.无效 -1.软删除)")
    @Column(comment = "是否有效(1.有效 0.无效 -1.软删除)", defaultValue = "1")
    @TableLogic(value = GlobalConstant.IS_VALID.YES_STR, delval = GlobalConstant.IS_VALID.DELETE_STR)
    private Integer valid;

    /**
     * 创建人
     *
     * @mbg.generated 2021-03-13 16:06:09
     */
    @TableField(fill = FieldFill.INSERT)
    @Column(isNull = false, comment = "创建人", defaultValue = "system")
    private String createBy;
    /**
     * 创建时间
     *
     * @mbg.generated 2021-03-13 16:06:09
     */
    @IsNativeDefValue
    @TableField(fill = FieldFill.INSERT)
    @Column(isNull = false, comment = "创建时间", type = MySqlTypeConstant.TIMESTAMP, defaultValue = "CURRENT_TIMESTAMP")
    private Date createTime;
    /**
     * 修改人
     *
     * @mbg.generated 2021-03-13 16:06:09
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Column(isNull = false, comment = "修改人", defaultValue = "system")
    private String modifyBy;
    /**
     * 修改时间
     *
     * @mbg.generated 2021-03-13 16:06:09
     */
    @IsNativeDefValue
    @Column(isNull = false, comment = "修改时间", type = MySqlTypeConstant.TIMESTAMP, defaultValue = "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date modifyTime;

}